-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Database SQL load #3
Conversation
WalkthroughThe changes primarily focus on enhancing the build process, refining logging levels, and restructuring the data fetching and loading mechanism in the Airport Lookup Service. The modifications also include the addition of a new Go package and updates to the database initialization process. Changes
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
=======================================
Coverage 92.92% 92.92%
=======================================
Files 2 2
Lines 99 99
=======================================
Hits 92 92
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 3
Configuration used: CodeRabbit UI
Files ignored due to filter (8)
- config/tarmac.json
- docker-compose.yml
- functions/src/data/load/go.mod
- functions/src/data/load/go.sum
- functions/src/init/go.mod
- functions/src/init/go.sum
- go.mod
- go.sum
Files selected for processing (4)
- Makefile (2 hunks)
- functions/src/data/fetch/main.go (1 hunks)
- functions/src/data/load/main.go (1 hunks)
- functions/src/init/main.go (2 hunks)
Files skipped from review due to trivial changes (2)
- Makefile
- functions/src/data/fetch/main.go
Additional comments: 4
functions/src/init/main.go (2)
1-6: The removal of unused imports is a good practice as it helps to keep the code clean and maintainable. Ensure that these removed packages are not used elsewhere in the code.
12-45: The function
Handler
is responsible for initializing the Airport Lookup Service, creating the MySQL database structure if it doesn't exist, and loading the airport data. The error handling and logging are done appropriately. However, consider using parameterized queries or prepared statements to prevent SQL injection attacks, even though the current query does not seem to be vulnerable.stmt, err := f.tarmac.SQL.Prepare(query) if err != nil { f.tarmac.Logger.Error(fmt.Sprintf("Failed to prepare statement - %s", err)) return []byte(""), fmt.Errorf("Failed to prepare statement: %s", err) } _, err = stmt.Exec() if err != nil { f.tarmac.Logger.Error(fmt.Sprintf("Failed to create table - %s", err)) return []byte(""), fmt.Errorf("Failed to create table: %s", err) }The function call to load airport data is done correctly. Ensure that the function "load" exists and is implemented correctly.
functions/src/data/load/main.go (2)
1-8: Imports look good. No unused imports detected.
14-37: The error handling and logging in the
Handler
method are well implemented. The function returns immediately when an error is encountered, and the error is logged with a descriptive message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- functions/src/data/load/main.go (1 hunks)
Additional comments: 4
functions/src/data/load/main.go (4)
1-9: Imports look good. No unused imports detected.
15-23: The error handling here is good. It logs the error and returns it.
25-38: The error handling here is good. It logs the error and returns it.
112-126: The error from the SDK initialization is not handled. As per the previous discussion, if the SDK fails to initialize, the logger might not be available. In such a scenario, you could consider returning an error from the main function, which would then be handled by the runtime. This approach might require changes in the way your program is run, depending on your runtime environment.
This code adds logic to load the database from the downloaded CSV file contents.
Summary by CodeRabbit
load.wasm
file using TinyGo.functions/build
directory and stop all services, ensuring a clean workspace.